package com.atguigu.gmall.product.controller;


import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.product.*;
import com.atguigu.gmall.product.service.ManageService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "SPU商品接口")
@RestController
@RequestMapping("admin/product")
@RefreshScope //自动刷新配置
public class SpuManageController {

    @Autowired
    private ManageService manageService;

    @ApiOperation("分页查询SPU数据")
    @GetMapping("{page}/{limit}")
    public Result spuInfoPage(@PathVariable Long page,
                              @PathVariable Long limit,
                              SpuInfo spuInfo){
        Page<SpuInfo> page1 = new Page<SpuInfo>(page,limit);
        IPage spuInfoIPage= manageService.spuInfoIPage(page1,spuInfo);
        return Result.ok(spuInfoIPage);
    }
}
